// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

const getLocaleLanguge = () => {
  let lang = globalThis.navigator.language || global.navigator.userLanguage
  return lang.sub(0, 2)
}

const i18n = new VueI18n({
  locale: 'zh', // 默认中文 --> 你可以从浏览器环境中读取当语言,也可以放后台返回. 因为 locale 后期是响应式的,一旦放生变化,也会及时更新页面
  messages: {
    zh: {
      login: '登录',
      register: '注册',
      changeLanguage: '切换语言'
    },
    en: {
      login: 'login',
      register: 'register',
      changeLanguage: 'changeLanguage'
    }
  }
})

import MyI18n from './MyI18n'
Vue.use(MyI18n)

new MyI18n({
  locale: 'zh',
  messages: {
    zh: {
      login: '登录',
      register: '注册',
      changeLanguage: '切换语言'
    },
    en: {
      login: 'login',
      register: 'register',
      changeLanguage: 'changeLanguage'
    }
  }
})

// console.log(Vue.prototype.$myi18n);

Vue.config.productionTip = false


/* eslint-disable no-new */
new Vue({
  el: '#app',
  i18n,
  components: { App },
  template: '<App/>'
})
